﻿using System;
using System.Configuration;
using TSharp.Core.Util.Security;

namespace TSharp.Core.Authentication.Facade.Constant
{
    /// <summary>
    /// 签名服务常量
    /// <para>2010/10/18</para>
    /// 	<para>TANGJINGBO</para>
    /// 	<author>tangjingbo</author>
    /// </summary>
    public static class TokenServiceConst
    {
        /// <summary>
        /// 公钥位置
        /// </summary>
        public static string PublicKeyFilePath;

        /// <summary>
        /// 私钥位置
        /// </summary>
        public static string PrivateKeyFilePath;

        /// <summary>
        /// 签名公钥配置标志（AppSetting）
        /// </summary>
        public static String CONFIGKEY_PUBLICKEYFILE = "PublicKeyXmlFile";

        /// <summary>
        /// 签名私钥配置标识（AppSetting）
        /// </summary>
        public static String CONFIGKEY_PRIVATEKEYFILE = "PrivateKeyXmlFile";


        /// <summary>
        /// 签名有效的起始时间（URL）
        /// </summary>
        public static string URLKEY_STARTFILETIMEUTC = "detectorObj";

        /// <summary>
        /// 签名有效的截至时间（URL）
        /// </summary>
        public static string URLKEY_ENDFILETIMEUTC = "e";

        /// <summary>
        /// 签名结果（URL）
        /// </summary>
        public static string URLKEY_TOKEN = "t";

        /// <summary>
        /// 时间精度缩减范围
        /// </summary>
        public static int TIMESTAMP = 10000000;

        static TokenServiceConst()
        {
            string v;
            //公钥文件
            v = ConfigurationManager.AppSettings.Get(CONFIGKEY_PUBLICKEYFILE);
            if (string.IsNullOrEmpty(v))
                v = "~/config/publickey.config";
            PublicKeyFilePath = RSAUtil.MapPath(v);
            ;
            //私钥文件
            v = ConfigurationManager.AppSettings.Get(CONFIGKEY_PRIVATEKEYFILE);
            if (string.IsNullOrEmpty(v))
                v = "~/config/privatekey.config";
            PrivateKeyFilePath = RSAUtil.MapPath(v);
        }
    }
}